package com.lj.universalframework.widget

import android.content.Context
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatImageView

/**
 * <p>文件名：PressedImageView
 * <p>创建者：LJ
 * <p>创建日期：2020\10\16 0016 14:22
 * <p>描述：
 */
class PressedImageView : AppCompatImageView {

    //按压颜色
    private var scaleSize  = 0f

    constructor(context: Context) : super(context) {
        scaleSize = 0.97f
    }

    constructor(context: Context, attrs: AttributeSet?) : super(context,attrs) {
        scaleSize = 0.97f
    }

    constructor(context: Context, attrs: AttributeSet?,defStyleAttr: Int) : super(context,attrs,defStyleAttr) {
        scaleSize = 0.97f
    }

    override fun setPressed(pressed: Boolean) {
        super.setPressed(pressed)
        if (isPressed) {
            scaleX = scaleSize
            scaleY = scaleSize
        } else {
            scaleX = 1.0f
            scaleY = 1.0f
        }
    }
}